package com.electronsys.dept.action;

import java.util.Comparator;
import java.util.List;

import com.electronsys.dept.service.IDeptService;
import com.electronsys.pojo.Log;
import com.electronsys.pojo.Module;
import com.electronsys.pojo.ModuleContent;
import com.opensymphony.xwork2.ActionSupport;

public class DeptLogListAction extends ActionSupport implements Comparator {
	private List<Log> llist;
	private IDeptService deptService;
	private Integer page = 1;
	private Integer totalPages;
	private static final Integer max = 5;
	private List<Module> mdlist;
	private List<ModuleContent> mclist;
	public String execute(){
		llist = deptService.logList(1001);
		int count = llist.size();

		totalPages = ((count % max) == 0)?(count / max):(count / max + 1);

		if(page < 1){
			page = 1;
		}
		if(page > totalPages){
			page = totalPages;
		}
		int start = (page - 1) * max ;
		llist = deptService.logListByPage(start,max);
		
		return SUCCESS;
	}
	public List<Log> getLlist() {
		return llist;
	}
	public void setLlist(List<Log> llist) {
		this.llist = llist;
	}
	public IDeptService getDeptService() {
		return deptService;
	}
	public void setDeptService(IDeptService deptService) {
		this.deptService = deptService;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public Integer getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(Integer totalPages) {
		this.totalPages = totalPages;
	}
	public static Integer getMax() {
		return max;
	}
	public List<Module> getMdlist() {
		return mdlist;
	}
	public void setMdlist(List<Module> mdlist) {
		this.mdlist = mdlist;
	}
	public List<ModuleContent> getMclist() {
		return mclist;
	}
	public void setMclist(List<ModuleContent> mclist) {
		this.mclist = mclist;
	}
	@Override
	public int compare(Object o1, Object o2) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
}
